<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title></title>
    <meta name="description" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="robots" content="all,follow">
    <!-- Bootstrap CSS-->
    <link rel="stylesheet" href="static/vendor/bootstrap/css/bootstrap.min.css">
    <!-- Font Awesome CSS-->
    <link rel="stylesheet" href="static/vendor/font-awesome/css/font-awesome.min.css">
    <!-- Fontastic Custom icon font-->
    <link rel="stylesheet" href="static/css/fontastic.css">
    <!-- Google fonts - Poppins -->
    <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Poppins:300,400,700">
    <!-- theme stylesheet-->
    <link rel="stylesheet" href="static/css/style.default.css" id="theme-stylesheet">
    <!-- Custom stylesheet - for your changes-->
    <link rel="stylesheet" href="static/css/custom.css">
    <link rel="stylesheet" href="static/css/fileinput.css">

    <!-- Favicon-->
    <link rel="shortcut icon" href="static/img/favicon.ico">
    <!-- Tweaks for older IEs-->
    <!--[if lt IE 9]>
        <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
        <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script><![endif]-->
</head>

<body>
    <div id="app">
        <div class="page">
            <!-- Main Navbar-->
            <header class="header">
                <nav class="navbar">
                    <!-- Search Box-->
                    <div class="search-box">
                        <button class="dismiss"><i class="icon-close"></i></button>
                        <form id="searchForm" action="#" role="search">
                            <input type="search" placeholder="What are you looking for..." class="form-control">
                        </form>
                    </div>
                    <div class="container-fluid">
                        <div class="navbar-holder d-flex align-items-center justify-content-between">
                            <!-- Navbar Header-->
                            <div class="navbar-header">
                                <!-- Navbar Brand -->
                                <a href="index.html" class="navbar-brand d-none d-sm-inline-block">
                                    <div class="brand-text d-none d-lg-inline-block"><span>淘书斋后台管理</span></div>
                            </div>
                            <!-- Navbar Menu -->
                            <ul class="nav-menu list-unstyled d-flex flex-md-row align-items-md-center">
                                <!-- Search-->
                                <li class="nav-item d-flex align-items-center">
                                    <a href="#"></a>
                                </li>

                                <!-- Logout    -->
                                <li class="nav-item">
                                    <li @click="logout()">
                                        <a href="#" class="nav-link logout"> <span class="d-none d-sm-inline">退出</span><i class="fa fa-sign-out"></i></a>
                                    </li>
                                </li>
                            </ul>
                        </div>
                    </div>
                </nav>
            </header>
            <div class="page-content d-flex align-items-stretch">
                <!-- Side Navbar -->
                <nav class="side-navbar">
                    <!-- Sidebar Header-->
                    <div class="sidebar-header d-flex align-items-center">
                        <div class="avatar"><img src="static/img/gao.jpg" alt="..." class="img-fluid rounded-circle"></div>
                        <div class="title">
                            <h1 class="h4">{{adminName}}</h1>
                            <p>管理员</p>
                        </div>
                    </div>
                    <!-- Sidebar Navidation Menus--><span class="heading">管理</span>
                    <ul class="list-unstyled">
                        <li>
                            <a href="index.html"> <i class="icon-home"></i>首页</a>
                        </li>
                        <li class="active">
                            <a href="#bookDownDropdown" aria-expanded="false" data-toggle="collapse"> <i class="icon-interface-windows"></i>书本管理</a>
                            <ul id="bookDownDropdown" class="collapse list-unstyled ">
                                <li><a href="book.html">书本列表</a></li>
                                <li><a href="booktype.html">书本类型列表</a></li>
                            </ul>
                        </li>

                        <li>
                            <a href="#orderDownDropdown" aria-expanded="false" data-toggle="collapse"> <i class="icon-interface-windows"></i>订单管理</a>
                            <ul id="orderDownDropdown" class="collapse list-unstyled ">
                                <li><a href="order.html">订单列表</a></li>
                            </ul>
                        </li>

                        <li>
                            <a href="#userDownDropdown" aria-expanded="false" data-toggle="collapse"> <i class="icon-interface-windows"></i>用户管理</a>
                            <ul id="userDownDropdown" class="collapse list-unstyled ">
                                <li><a href="user.html">用户列表</a></li>

                            </ul>
                        </li>


                    </ul><span class="heading">设置</span>
                    <ul class="list-unstyled">
                        <li>
                            <a href="role.html"> <i class="icon-flask"></i>权限管理 </a>
                        </li>
                    </ul>
                </nav>
                <div class="content-inner">
                    <!-- Page Header-->
                    <header class="page-header">
                        <div class="container-fluid">
                            <h2 class="no-margin-bottom">淘书斋</h2>
                        </div>
                    </header>
                    <!-- Breadcrumb-->
                    <div class="breadcrumb-holder container-fluid">
                        <ul class="breadcrumb">
                            <li class="breadcrumb-item"><a href="order.html">书本类型列表</a></li>
                            <li class="breadcrumb-item active">添加书本类型 </li>
                        </ul>
                    </div>
                    <!-- Forms Section-->

                    <section class="forms">
                        <div class="container-fluid">
                            <div class="row">

                                <!-- Form Elements -->
                                <div class="col-lg-12">
                                    <div class="card">
                                        <div class="card-close">
                                            <div class="dropdown">
                                                <button type="button" id="closeCard5" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" class="dropdown-toggle"><i class="fa fa-ellipsis-v"></i></button>

                                            </div>
                                        </div>
                                        <div class="card-header d-flex align-items-center">
                                            <h3 class="h4">书本类型信息</h3>
                                        </div>
                                        <div class="card-body">
                                            <form class="form-horizontal">
                                                <div v-if="typeNameValid==='0'" class="form-group row">
                                                    <label class="col-sm-1 form-control-label">名称</label>
                                                    <div class="col-sm-6">
                                                        <input v-model="bookType.typeName" type="text" placeholder="请输入名称" class="form-control" @change="typeNameChange()">
                                                    </div>
                                                </div>

                                                <div v-else-if="typeNameValid==='1'" class="form-group row has-success">

                                                    <label class="col-sm-1 form-control-label">名称</label>
                                                    <div class="col-sm-6">
                                                        <input v-model="bookType.typeName" type="text" placeholder="请输入名称" class="form-control is-valid" @change="typeNameChange()">
                                                    </div>
                                                </div>

                                                <div v-else class="form-group row has-danger">

                                                    <label class="col-sm-1 form-control-label">名称</label>
                                                    <div class="col-sm-6">
                                                        <input v-model="bookType.typeName" type="text" placeholder="请输入名称" class="form-control is-invalid" @change="typeNameChange()">
                                                        <div class="invalid-feedback">请输入名称</div>
                                                    </div>
                                                </div>

                                                <div class="line "></div>
                                                <!-- <div class="form-group row has-success ">
                                                <label class="col-sm-3 form-control-label ">Input with success</label>
                                                <div class="col-sm-9 ">
                                                    <input type="text " class="form-control is-valid ">
                                                </div>
                                            </div>
                                            <div class="line "></div>
                                            <div class="form-group row has-danger ">
                                                <label class="col-sm-3 form-control-label ">Input with error</label>
                                                <div class="col-sm-9 ">
                                                    <input type="text " class="form-control is-invalid ">
                                                    <div class="invalid-feedback ">Please provide your name.</div>
                                                </div>
                                            </div>
                                            <div class="line "></div> -->

                                                <!-- <div class="form-group row ">
                                                <label class="col-sm-3 form-control-label ">Button addons</label>
                                                <div class="col-sm-9 ">
                                                    <div class="form-group ">
                                                        <div class="input-group ">
                                                            <div class="input-group-prepend ">
                                                                <button type="button " class="btn btn-primary ">Go!</button>
                                                            </div>
                                                            <input type="text " class="form-control ">
                                                        </div>
                                                    </div>
                                                    <div class="form-group ">
                                                        <div class="input-group ">
                                                            <input type="text " class="form-control ">
                                                            <div class="input-group-append ">
                                                                <button type="button " class="btn btn-primary ">Go!</button>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div> -->

                                                <div class="form-group row ">
                                                    <div class="col-sm-4 offset-sm-3 ">
                                                        <button type="button" class="btn btn-secondary" @click="back()">取消</button>
                                                        <button type="button" class="btn btn-primary" @click="save()">保存</button>
                                                    </div>
                                                </div>
                                            </form>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </section>

                    <!-- Page Footer-->
                    <footer class="main-footer ">
                        <div class="container-fluid ">
                            <div class="row ">
                                <div class="col-sm-6 ">
                                    <p>Copyright &copy; 2019.Company name All rights reserved.More Templates <a href="http://www.cssmoban.com/ " target="_blank " title="模板之家 ">模板之家</a> - Collect from <a href="http://www.cssmoban.com/ " title="网页模板
                                                        " target="_blank ">网页模板</a></p>
                                </div>
                                <div class="col-sm-6 text-right ">
                                    <p></p>
                                    <!-- Please do not remove the backlink to us unless you support further theme's development at https://bootstrapious.com/donate. It is part of the license conditions. Thank you for understanding :)-->
                                </div>
                            </div>
                        </div>
                    </footer>
                </div>
            </div>
        </div>
    </div>
    <!-- JavaScript files-->
    <script src="static/vendor/jquery/jquery.min.js "></script>
    <script src="static/vendor/popper.js/umd/popper.min.js ">
    </script>
    <script src="static/vendor/bootstrap/js/bootstrap.min.js "></script>
    <script src="static/vendor/jquery.cookie/jquery.cookie.js ">
    </script>
    <script src="static/vendor/chart.js/Chart.min.js "></script>
    <script src="static/vendor/jquery-validation/jquery.validate.min.js "></script>
    <!-- Main File-->
    <script src="static/js/front.js "></script>
    <script src="static/node_modules/vue/dist/vue.js"></script>

    <script>
        var vm = new Vue({
            el: '#app',
            data: {
                adminName: '',
                //服务器:http://47.100.136.219
                serverIp: 'http://47.100.136.219',
                ifLocal: false,

                bookType: {
                    typeName: ''
                },

                typeNameValid: '0'

            },

            mounted() {
                let _this = this;
                if (this.ifLocal) {
                    this.serverIp = "http://localhost";
                }


                $.ajax({
                    type: "GET",
                    url: _this.serverIp + ":8088/boot/admincommon/info",
                    success: function(response) {
                        if (response.code == 200) {
                            console.log(response.data);
                            _this.adminName = response.data.data.principal.username
                        }
                    },

                });

            },

            methods: {

                logout() {
                    let _this = this;
                    $.ajax({
                        url: _this.serverIP + ':8088/boot/logout',
                        type: 'POST',
                        success: function(res, status) {
                            console.log(res);
                            location.href = "login.html";

                        },
                        error: function(res, status) {
                            console.log(res);
                        }
                    });
                },


                back() {
                    location.href =
                        "booktype.html";
                },



                save() {
                    let _this = this;

                    if (_this.typeNameValid != "1") {
                        alert("请填写类型!");
                        return;
                    }

                    console.log("开始提交数据");
                    $.ajax({
                        type: "POST",
                        url: _this.serverIp + ":8088/boot/adminbook/booktype",
                        data: JSON.stringify(_this.bookType), //必要
                        dataType: "json",
                        contentType: "application/json",
                        success: function(response) {
                            if (response.code == 200) {
                                console.log(response.data);

                                location.href =
                                    "booktype.html";


                            } else if (response.code == 403) {
                                alert(response.msg);

                            }
                        },

                    });


                },

                typeNameChange() {
                    let _this = this;

                    if (_this.bookType.typeName == "") {
                        _this.typeNameValid = "-1";
                    } else {
                        _this.typeNameValid = "1";
                    }
                },


            },



        });
    </script>
</body>

</html>